package com.lagou.controller;

import com.github.pagehelper.PageInfo;
import com.lagou.pojo.Article;
import com.lagou.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/pageInfo")
    public String pageInfo(Model model, @RequestParam(defaultValue = "1")Integer pageNum){
        PageInfo<Article> pageInfo = articleService.findArticle(pageNum, 2);
        //往前台传递数据
        model.addAttribute("pageInfo",pageInfo);
        System.out.println(pageInfo.getList());
        return "index";
    }
}
